﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DBUtil.Util
{
    /// <summary>
    /// 返回格式
    /// </summary>
    public class ResultUtil
    {
        /// <summary>
        /// 包装返回结果
        /// </summary>
        /// <param name="action">要包装的执行逻辑</param>
        /// <returns></returns>
        public static (bool success, string message) WrapRes(Action action)
        {
            if (action == null) return (true, null);
            try
            {
                action();
                return (true, null);
            }
            catch (Exception ex)
            {
                return (false, ex?.Message);
            }
        }
    }
}
